package demo1;

import java.util.Stack;

public class Test {
    public static void test(Animal animal){
        animal.eat();
    }

    public static void run(IRunAble iRunAble){
        iRunAble.run();
    }//不必关注类的具体类型，只用关注类是否具备某种能力，即是否有这个接口

    public static void main(String[] args) {
        Dog dog = new Dog("狗",3);
        Bird bird = new Bird("鸟",2);
        Duck duck = new Duck("鸭子",1);
        Robot robot = new Robot("机器人");

        run(dog);
        run(duck);
        run(robot);
    }

    public static void main1(String[] args) {
        Dog dog = new Dog("狗",3);
        Bird bird = new Bird("鸟",2);
        Duck duck = new Duck("鸭子",1);

        test(dog);
        test(bird);
        test(duck);
    }
}
